/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import java.io.Serializable;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import jpa.controller.FornecedorJpaController;
import jpa.entity.Fornecedor;
import jpa.util.SharedPersistFornecedor;

/**
 *
 * @author isaias
 */
@ManagedBean
@RequestScoped
public class FornecedorBean implements Serializable{
     private String fornecedorNameFilter = "";
     private Fornecedor fornecedor = new Fornecedor();
     private Fornecedor fornecedorSelected = new Fornecedor();
    /** Creates a new instance of DistribuidorBean */
    public FornecedorBean() {
    }

    public List<Fornecedor> getFornecedoresList(){
        return new FornecedorJpaController().findFornecedorEntitiesByName(fornecedorNameFilter);
    }

    public void saveFornecedor(){
         SharedPersistFornecedor.merge(fornecedor, true, true);
         fornecedor = new Fornecedor();
    }

    public Fornecedor getFornecedor() {
        return fornecedor;
    }

    public void setFornecedor(Fornecedor fornecedor) {
        this.fornecedor = fornecedor;
    }

    public Fornecedor getFornecedorSelected() {
        return fornecedorSelected;
    }

    public void setFornecedorSelected(Fornecedor fornecedorSelected) {
        this.fornecedorSelected = fornecedorSelected;
    }

    public String getFornecedorNameFilter() {
        return fornecedorNameFilter;
    }

    public void setFornecedorNameFilter(String fornecedorNameFilter) {
        this.fornecedorNameFilter = fornecedorNameFilter;
    }
    
    

}
